copy (count of (generic boxes whose selected is true)) to numSelected
if numSelected = 0 then
beep
display dialog "Check a box is selected and" & return & "that it is on the current page." buttons "OK" default button 1 with icon 1
do updates
else if numSelected is not 1 then
beep
display dialog "" & numSelected & " items have been selected." & return & "(Only one box can be used at a time)." buttons "OK" default button 1 with icon 2
do updates
else if (box type of generic boxes whose selected is true) = line box then
beep
display dialog "Cannot use lines." buttons "OK" default button 1 with icon 2
do updates
else
copy bounds of x as list to boxBounds
copy item 1 of boxBounds as real to bounds1
copy item 2 of boxBounds as real to bounds2
copy item 3 of boxBounds as real to bounds3
copy item 4 of boxBounds as real to bounds4
copy (display dialog "Set guides to selected box:" with icon 2000) to x
do updates
if button returned of x is "OK" then
make horizontal guide at beginning with properties {position:bounds1}
make horizontal guide at beginning with properties {position:bounds3}
make vertical guide at beginning with properties {position:bounds2}
make vertical guide at beginning with properties {position:bounds4}